#ifndef BTNDELEGATE_H
#define BTNDELEGATE_H

#include "comui_global.h"

#include <QObject>
#include <QPushButton>
#include <QStyledItemDelegate>
#include <QSharedPointer>
#include <QList>

class COMUISHARED_EXPORT TableViewBtnDelegate: public QStyledItemDelegate
{
    Q_OBJECT

public:
    explicit TableViewBtnDelegate(QStringList btnNames, QWidget *parent = 0);
    ~TableViewBtnDelegate();
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index);

signals:
    void oper(const QModelIndex &index, QString oper);
    void editData(const QModelIndex &index);
    void deleteData(const QModelIndex &index);

private:
    QPoint m_mousePoint;  // 鼠标位置
    int m_nType;  // 按钮状态：0-划过 1-按下
    QStringList m_btnNames;
    std::vector<QSharedPointer<QPushButton>> m_btns;
};



#endif // BTNDELEGATE_H
